<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var arr = [1,3,4,22,2,5];
        // // arr.sort();  // 不可以 ，没有传回调函数 sort 会根据 ASSCI码来排序 
        // arr.sort(function(a,b){
        //     return a - b;
        // })
        // console.log(arr);


        var arr  = [{name:"张三",age:20},{name:"张三",age:23},{name:"张三",age:22}];

        arr.sort(function(a,b){
            // return a.age - b.age;
            return b.age-a.age;
        })

        console.log(arr);


    </script>
</body>
</html>